package v1

import (
	"gitee.com/buddyxiao/ginblog/model"
	"gitee.com/buddyxiao/ginblog/utils/errmsg"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Upload(context *gin.Context) {
	file,fileHeader,_ := context.Request.FormFile("file")
	fileSize := fileHeader.Size
	url, code := model.UploadFile(file,fileSize)
	context.JSON(http.StatusOK,gin.H{
		"status": code,
		"msg": errmsg.GetErrMsg(code),
		"url": url,
	})

}
